<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>

</head>
<body class="gray-bg">
<div class="container creditbody">
	<div class="iboxtitle">
		<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;贷中业务>车牌登记</span>
		<a href="javascript:void(0)"></a>
	</div>
	<div class="buttonfixed">
       <button type="button" class="btn dpbtn_blue" id="registrationPlates">保存提交</button>
    </div>
	<div class="ibox-content ibox-con">
		<form class="form-horizontal" id="commentForm">
		<%@include file="/jsp/common_yw_include.jsp"%>
		<%@include file="/jsp/common_car_include.jsp"%>
		<div class="business-manwife">上牌信息</div>
        <div class="padding-nono">
    		  <table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
    		  	<input id="id" name="id" value="${dzRegistration.id }" type="hidden" />	
				<tr>	
					<td align="right">
						<label class="control-label np">上牌地：</label>
					</td>
					<td colspan="4">
						<input class="form-control smalliconcur smallicon" type="text" readonly="readonly" value="${dzRegistration.regionRegistration }" onclick="cityChoice(this);" id="regionRegistration"  required="required" name="regionRegistration" placeholder="上牌地(必填)" />
					</td>
				</tr>
				
				<tr>	
				   <td align="right">
						<label class="control-label np">车管所：</label>
					</td>
						
					<td>
						<input id="dvm" name="dvm" placeholder="车管所(必填)" class="form-control" required="required" value="${dzRegistration.dvm }"/>
					</td>
					<td align="right">
						<label class="control-label np">车牌号：</label>
					</td>
					<td>
						<input id="licensePlate" name="licensePlate" placeholder="车牌号(必填)" maxlength="10" class="form-control" required="required" value="${dzRegistration.licensePlate }"/>
					</td>
					</td>
				</tr>
				
				<tr>	
					<td align="right">
						<label class="control-label np">机动车登记证书号：</label>
					</td>
						
					<td>
						<input id="registrationNumber" name="registrationNumber" class="form-control" required="required" placeholder="机动车登记证书号(必填)" value="${dzRegistration.registrationNumber }"/>
					</td>
					
					<td align="right">
						<label class="control-label np">车辆初次登记：</label>
					</td>
					<td>
						<input id="dateRegistrationFirst" name="dateRegistrationFirst" placeholder="车辆初次登记时间(必填)" required="required" class="laydate-icon form-control"  value='<fmt:formatDate value="${dzRegistration.dateRegistrationFirst }" pattern="yyyy-MM-dd"/>'/>
					</td>
				</tr>
				
				<tr>	
					<td align="right">
						<label class="control-label np">本次上牌时间：</label>
					</td>
					<td>
						<input id="dateRegistrationNow" name="dateRegistrationNow" placeholder="本次上牌登记时间(必填)" required="required" class="laydate-icon form-control" value='<fmt:formatDate value="${dzRegistration.dateRegistrationNow }" pattern="yyyy-MM-dd"/>'/>
					</td>
				</tr>
				<tr>
					<td align="right" valign="top">
						<label class="control-label np">备注：</label>
					</td>
					<td colspan="3">
						<textarea id="remarks" rows="2" class="form-control">${dzRegistration.remarks }</textarea>
					</td>
				</tr>
			</table>
    	</div>
    	
		<!-- 当前经办人 -->
    	<%@include file="/jsp/comm_current_person_include.jsp"%>

	</form>
</div>	
	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>
    <!-- summernote -->
 	<%@include file="/js/common-dpqc/dpqc-summernote/comm_summernote_include.jsp"%>
 	
 	<%@include file="/jsp/comm_js_region_include_choice.jsp"%>
 	
    <!-- layerDate plugin javascript -->
    <script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
    
    <!-- custom js -->
    
    <!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
    <script type="text/javascript">
    
    	/* if($('#id').val() && $('#id').val().trim() != '') {
    		$('#registrationPlates').hide();
    	} */
		
    	/* 省市区默认选择 */
	 	var hujilayer,objid;
	 	
	 	function cityChoice(obj){
	 		selectProvincesLayer(null,function(){
	 			$selectedProvice = $("#provincechioce").children("li:eq(0)")
	 			$selectedProvice.addClass("proactive"); 
	 			selectCitiesLayer("110000000000",null, function(){
	 				$("#citychioce").children("li:eq(0)").addClass("proactive"); 
		 			selectAreasLayer("110100000000");
		    	});
	 		});
	 		objid = $(obj).attr("id");
	 		 
	 		hujilayer = layer.open({
	 			type:1,
	 			title:"省市选择",
	 			area: ['650px', '500px'], //宽高
	 			content: $("#areaChoice")
	 		});
	 	};
	 	
	 	function areachoiceone(obj){
	 		var province = $("#provincechioce").find("li.proactive").text();
	 		var city = $("#citychioce").find("li.proactive").text();
	 		var area = $(obj).text();
	 		if(area == "未知地区"){
	 			area="";
	 		}
	 		var text = province + city + area;
	 		if(objid=="regionRegistration"){
	 			$("#regionRegistration").val(text);
	 		}
	 		layer.close(hujilayer);
	 	} 
    	
		$(function(){
	         $("#commentForm").validate({
	             //重写showErrors
	             showErrors: function (errorMap, errorList) {
	                 
	                 $.each(errorList, function (i, v) {
	                     layer.tips(v.message, v.element, { time: 1500 });
	                     return false;
	                 });  
	             },
	             /* 失去焦点时验证 */
	             onfocusout: function(element) { $(element).valid(); },
	             /*  键盘抬起不验证 */
	             onkeyup:false,
	         });
	         
		    	 //省份/城市选择
		        $("#province").change(function(){
		    		var province = $("#province").val();
		    		selectCities(province);
		        });
		    	
		        $('#registrationPlates').click(function(){
		        	registrationPlates();
		        });
		        
		    	laydate({
			        elem: '#dateRegistrationFirst', 
			        event: 'focus',
			        max:laydate.now()
			    });
		    	laydate({
			        elem: '#dateRegistrationNow', 
			        event: 'focus',
			        max:laydate.now()
			    });
	  	});
    	
	  //保存车牌登记记录
	    function registrationPlates(){
	    	var validstatus = $("#commentForm").valid();
  	    	if(validstatus)
  	    	{
		    	var data = {};
				data.id = $("#id").val();
				data.busiId = $("#busiId").val();
				data.cusId = $("#customerId").val();
				data.carId = $('#carId').val();
		 		data.regionRegistration = $("#regionRegistration").val();
				data.dvm = $('#dvm').val();
				data.licensePlate = $('#licensePlate').val();
				data.registrationNumber = $('#registrationNumber').val();
				data.dateRegistrationFirst = $('#dateRegistrationFirst').val();
				data.dateRegistrationNow = $('#dateRegistrationNow').val();
				data.remarks = $('#remarks').val();
				layer.confirm('是否确认执行操作？操作人：<span style="color:#BD1723;">${current_user_key.uname}</span>', {
			    	  btn: ['确定','取消'] //按钮
			    	}, function(){
		    		layer.closeAll();
					$.dpAjax({
		 	    		url:'${basePath}/DzRegistrationController/registrationPlates',
		     			data:data,
		     			success: function(datas){
		     				 layer.msg("保存车牌登记成功！", {icon: 6,time:3000});
		     				 $('#id').val(datas.result);
		     				// $('#registrationPlates').hide();
		                 }
		 	    	});
			   })	
  	    	}	
	    }
	  
    </script>
</body>
</html>
